<?php
//$this->Html->script(array('plugins/datatables/jquery.dataTables.min'), false);
?>
<?php
echo $this->Form->create('Paginate', array(
	'class' => 'validate',
	'action' => 'index',
	'url' => $this->request->here(false),
	'type' => 'post',
	'inputDefaults' => array('label' => false, 'div' => false)));
echo $this->Form->input('Paginate.task', array('style' => 'display:none;', 'value' => '', 'id' => 'task'));
?>
<div class="page-header clearfix">
	<h1>
		<?php echo __('Rewards management'); ?> 
		<?php //echo __('ONLINE LUCKY DRAW SYSTEM'); ?>
	</h1>
	<div class="page-toolbar pull-right">
		<div class="btn-group ctr-container">
			<a class="btn btn-primary ctr-add" href="<?php echo Router::url(array('action' => 'add')) ?>">
				<span class="ico-add"></span>
				<?php echo __('Add new reward'); ?>
			</a>
			<a class="btn btn-primary ctr-add" href="<?php echo Router::url(array('controller' => 'users')) ?>">
				<span class="ico-add"></span>
				<?php echo __('Users management'); ?>
			</a>
			<a class="btn btn-primary ctr-add" href="<?php echo Router::url(array('controller' => 'users', 'action' => 'config')) ?>">
				<span class="ico-add"></span>
				<?php echo __('Configuration'); ?>
			</a>
		</div>
	</div>
</div>

<div class="row-fluid">
	<div class="span12">
		<div class="block">
			<?php
			$continue = array(
				'?' => array('continue' => $this->request->here(false))
			);
			echo $this->Session->flash();
			$count = count($rewards);
			?>
			<div class="data-fluid">
				<table class="table paginate lcnp" cellpadding="0" cellspacing="0" width="100%">
					<thead>
						<tr>
							<th width="20%"><?php echo __('Name'); ?></th>
							<th width="10%"><?php echo __('Percentage'); ?></th>
							<th width="30%"><?php echo __('Frequency (Parse from Percentage)'); ?></th>
							<th width="80"><?php echo __('Color'); ?></th>
							<th width="80"><?php echo __('weight'); ?></th>
							<th width="60" class="TAC">Actions</th>
						</tr>
					</thead>
					<tbody>
						<?php foreach ($rewards as $reward) : ?>
							<tr>
								<td>
									<?php echo $reward['Reward']['name']; ?>
								</td>
								<td>
									<?php echo number_format($reward['Reward']['percentage'], 2, '.', ' '); ?>
								</td>
								<td style="color: #f00;">
									<?php echo floor($reward['Reward']['percentage'] * $count * 10); ?>
								</td>
								<td>
									<span style="display: inline-block; width: 5em; color: #<?php echo $reward['Reward']['color']; ?>">
										<?php echo $reward['Reward']['color']; ?>
									</span>
								</td>
								<td>
									<?php echo $reward['Reward']['weight'] ?>
								</td>
								<td class="table-action">
									<?php
									echo $this->Html->link(__('Delete'), $continue + array('action' => 'delete', $reward['Reward']['id']), array(
										'class' => 'btn btn-primary'
											), 'You want to delete?');
									?>
									<a href="<?php echo $this->Html->url($continue + array('action' => 'edit', $reward['Reward']['id'])); ?>" class="btn btn-primary">
										<?php echo __('Edit'); ?>
									</a>
								</td>
							</tr>
						<?php endforeach; ?>                         
					</tbody>
				</table>                    
			</div> 
		</div>
	</div>
</div>
<?php echo $this->Form->end(); ?>
<style type="text/css">
	.paginate tr.disabled td,.paginate tr.disabled td a{
		color: #f00 !important;
	}
</style>